package com.ruoyi.web.controller.ring;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ring.domain.RingHrv;
import com.ruoyi.ring.service.IRingHrvService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 心率变异性
 * 
 * @author liuwp
 * @date 2025-08-22
 */
@RestController
@RequestMapping("/ring/ring_hrv")
public class RingHrvController extends BaseController
{
    @Autowired
    private IRingHrvService ringHrvService;

    /**
     * 查询心率变异性列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_hrv:list')")
    @GetMapping("/list")
    public TableDataInfo list(RingHrv ringHrv)
    {
        startPage();
        List<RingHrv> list = ringHrvService.selectRingHrvList(ringHrv);
        return getDataTable(list);
    }

    /**
     * 导出心率变异性列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_hrv:export')")
    @Log(title = "心率变异性", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RingHrv ringHrv)
    {
        List<RingHrv> list = ringHrvService.selectRingHrvList(ringHrv);
        ExcelUtil<RingHrv> util = new ExcelUtil<RingHrv>(RingHrv.class);
        util.exportExcel(response, list, "心率变异性数据");
    }

    /**
     * 获取心率变异性详细信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_hrv:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ringHrvService.selectRingHrvById(id));
    }

    /**
     * 新增心率变异性
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_hrv:add')")
    @Log(title = "心率变异性", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RingHrv ringHrv)
    {
        return toAjax(ringHrvService.insertRingHrv(ringHrv));
    }

    /**
     * 修改心率变异性
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_hrv:edit')")
    @Log(title = "心率变异性", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RingHrv ringHrv)
    {
        return toAjax(ringHrvService.updateRingHrv(ringHrv));
    }

    /**
     * 删除心率变异性
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_hrv:remove')")
    @Log(title = "心率变异性", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ringHrvService.deleteRingHrvByIds(ids));
    }

}
